package com.example.logingithub.controller;

import org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken;
import org.springframework.security.oauth2.core.user.DefaultOAuth2User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;

/**
 * @author jl
 * Created on 2020/10/21
 */
@RestController
public class HelloController {

    @GetMapping("/hello")
    public DefaultOAuth2User user(Principal principal) {
        return (DefaultOAuth2User) ((OAuth2AuthenticationToken) principal).getPrincipal();


    }
}
